
<!--_meta 作为公共模版分离出去-->
{include file="public/_meta"}

<style>
	.Hui-iconfont{position: relative;top: -27px; left:680px; cursor:pointer; display: none; width: 5px;
		height: 5px;}
</style>

<article class="page-container">
	<form action="" method="post" class="form form-horizontal" id="form-change-password">
		<input id="user_id" type="hidden" value="{$user['id']}" name="id">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>账户：</label>
			<div class="formControls col-xs-7 col-sm-8"> {$user['username']} </div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>原密码：</label>
			<div class="formControls col-xs-7 col-sm-8">
				<input id="now_password" type="password" class="input-text password" autocomplete="off" placeholder="请输入原始密码" name="now_password">
			</div>
			<i class="Hui-iconfont">&#xe725;</i>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>新密码：</label>
			<div class="formControls col-xs-7 col-sm-8">
				<input id="password" type="password" class="input-text password" autocomplete="off" placeholder="请输入新密码" name="password">
			</div>
			<i class="Hui-iconfont">&#xe725;</i>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认密码：</label>
			<div class="formControls col-xs-7 col-sm-8">
				<input id="repassword" type="password" class="input-text password" autocomplete="off" placeholder="请输入确认密码" name="repassword">
			</div>
			<i class="Hui-iconfont">&#xe725;</i>
		</div>
		<div class="row cl">
			<div class="col-xs-7 col-sm-8 col-xs-offset-4 col-sm-offset-3">
				<input id="edit_password" class="btn btn-primary btn6 radius size-M" type="submit" value="确认修改">
				<button onClick="parent.layer.close(parent.layer.getFrameIndex(window.name));" class="btn btn6 size-M radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;&nbsp;&nbsp;</button>

			</div>
		</div>
	</form>
</article>

<!--_footer 作为公共模版分离出去-->
{include file="public/_footer"}

<script type="text/javascript">
$(function(){

	/*修改密码*/
	$("#form-change-password").validate({
		rules:{
			/*now_password:{
				required:true,
			},
			password:{
				required:true,
				minlength:5,
				maxlength:16,
			},
			repassword:{
				required:true,
				minlength:5,
				maxlength:16,
				equalTo: "#password"
			},*/
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			var id = document.getElementById('user_id').value;
			var now_password = document.getElementById('now_password').value;
			var password = document.getElementById('password').value;
			var repassword = document.getElementById('repassword').value;
			$(form).ajaxSubmit({
				type: 'post',
				url: "{:url('member/edit_password')}",
				dataType: 'json',
				data: {
					id:id,
					now_password:now_password,
					password:password,
					repassword:repassword
				},
				success: function(msg){
					if(msg.status == false){
						layer.msg(msg.message,{icon: 5,time:1000});
					}else if(msg.status == true){
						layer.msg(msg.message,{icon: 6,time:1000});
						setTimeout(jump,1000);
						function jump(){
							parent.location.reload();
						}
					}
				}
			});
			//var index = parent.layer.getFrameIndex(window.name);
			//parent.$('.btn-refresh').click();
			//parent.layer.close(index);
		}
	});
});
</script>
<script>

	/*密码隐藏和密码显现*/
	var aInp = document.getElementsByClassName("password");
	var aI = document.getElementsByTagName("i");

	for(var i=0;i<aInp.length;i++){
		aInp[i].index = i;
		aInp[i].onkeydown = function () {
			aI[this.index].style.display = "block";
		}
	}
	for(var j=0;j<aI.length;j++){
		aI[j].index = j;
		oldtype = aInp[j].type;
		aI[j].onmousedown = function () {
			aInp[this.index].setAttribute('type', 'text');
		};
		aI[j].onmouseup = function () {
			aInp[this.index].setAttribute('type', oldtype);
		}
	}

</script>